-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

=============================================================================
FreeBSD-SA-21:13.bhyve                                      Security Advisory
                                                          The FreeBSD Project

Topic:          Missing error handling in bhyve(8) device models

Category:       core
Module:         bhyve
Announced:      2021-08-24
Credits:        Agustin Gianni (GitHub Security Lab)
Affects:        All supported versions of FreeBSD.
Corrected:      2021-08-24 18:29:48 UTC (stable/13, 13.0-STABLE)
                2021-08-24 17:33:35 UTC (releng/13.0, 13.0-RELEASE-p4)
                2021-08-24 18:33:04 UTC (stable/12, 12.2-STABLE)
                2021-08-24 18:32:13 UTC (releng/12.2, 12.2-RELEASE-p10)
                2021-08-24 18:33:02 UTC (stable/11, 11.4-STABLE)
                2021-08-24 18:31:27 UTC (releng/11.4, 11.4-RELEASE-p13)
CVE Name:       CVE-2021-29631

For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit <URL:https://security.FreeBSD.org/>.

I.   Background

bhyve(8) is a hypervisor that supports running a variety of guest
operating systems in virtual machines.  It implements a number of device
models using the VirtIO interface to exchange data between the guest and
the host.

II.  Problem Description

Certain VirtIO-based device models failed to handle errors when fetching
I/O descriptors.  Such errors could be triggered by a malicious guest.
As a result, the device model code could be tricked into operating on
uninitialized I/O vectors, leading to memory corruption.

III. Impact

A malicious guest may be able to crash the bhyve process.  It may be
possible to exploit the memory corruption bugs to achieve arbitrary code
execution in the bhyve process.

IV.  Workaround

No workaround is available.  Virtual machines are unaffected unless they
use one or more of the following device models:

* virtio-console
* virtio-rnd
* virtio-scsi (available starting in FreeBSD 12.0)
* virtio-9p (available starting in FreeBSD 13.0)

V.   Solution

Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date.

Perform one of the following:

1) To update your vulnerable system via a binary patch:

Systems running a RELEASE version of FreeBSD on the amd64, i386, or
(on FreeBSD 13 and later) arm64 platforms can be updated via the
freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install

2) To update your vulnerable system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

[FreeBSD 13.0]
# fetch https://security.FreeBSD.org/patches/SA-21:13/bhyve.13.patch
# fetch https://security.FreeBSD.org/patches/SA-21:13/bhyve.13.patch.asc
# gpg --verify bhyve.13.patch.asc

[FreeBSD 12.2]
# fetch https://security.FreeBSD.org/patches/SA-21:13/bhyve.12.patch
# fetch https://security.FreeBSD.org/patches/SA-21:13/bhyve.12.patch.asc
# gpg --verify bhyve.12.patch.asc

[FreeBSD 11.4]
# fetch https://security.FreeBSD.org/patches/SA-21:13/bhyve.11.patch
# fetch https://security.FreeBSD.org/patches/SA-21:13/bhyve.11.patch.asc
# gpg --verify bhyve.11.patch.asc

b) Apply the patch.  Execute the following commands as root:

# cd /usr/src
# patch < /path/to/patch

c) Recompile the operating system using buildworld and installworld as
described in <URL:https://www.FreeBSD.org/handbook/makeworld.html>.

VI.  Correction details

This issue is corrected by the corresponding Git commit hash or Subversion
revision number in the following stable and release branches:

Branch/path                             Hash                     Revision
- -------------------------------------------------------------------------
stable/13/                              20f96f215562    stable/13-n246941
releng/13.0/                            ec08bc89d4b3  releng/13.0-n244756
stable/12/                                                        r370400
releng/12.2/                                                      r370393
stable/11/                                                        r370399
releng/11.4/                                                      r370386
- -------------------------------------------------------------------------

For FreeBSD 13 and later:

Run the following command to see which files were modified by a
particular commit:

# git show --stat <commit hash>

Or visit the following URL, replacing NNNNNN with the hash:

<URL:https://cgit.freebsd.org/src/commit/?id=NNNNNN>

To determine the commit count in a working tree (for comparison against
nNNNNNN in the table above), run:

# git rev-list --count --first-parent HEAD

For FreeBSD 12 and earlier:

Run the following command to see which files were modified by a particular
revision, replacing NNNNNN with the revision number:

# svn diff -cNNNNNN --summarize svn://svn.freebsd.org/base

Or visit the following URL, replacing NNNNNN with the revision number:

<URL:https://svnweb.freebsd.org/base?view=revision&revision=NNNNNN>

VII. References

<URL:https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-29631>

The latest revision of this advisory is available at
<URL:https://security.FreeBSD.org/advisories/FreeBSD-SA-21:13.bhyve.asc>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE/A6HiuWv54gCjWNV05eS9J6n5cIFAmElV10ACgkQ05eS9J6n
5cLrsw//SuInBQjVhNXa1OkC7FcBve+vQCmgThGAxJVrFpRdHxg/q3Vfyza3/V1w
FGUiPPhAsF3wYwK9UqMS5a3dOI3WbaUvH8dDeLd3BLj4AfFE3uTOFC0xzmdBQcm0
2mFbTRkL0Wqb6FpDiswdu1s9jp1JggIa+SGuajl4XaoIyM/tek3PFuEOeE2v2N7E
djKciPwFnsRneFQIOTHVqa0mut5AilNI9WwKZgv3qzqQNnAasBpbiZKG/BhA2mZm
GLm0NtI40BdnIW3mfGYqK3r/tXUi/tcMSHzV2NDOGToB5wHj6Ah1lQ8pUEVnLo0d
TeDrioK/z53wqLhHUSsxdifST6JX0CQ2kf7qb256mE3o9brRyD2s6AM2Bld3r/ov
wzPTIzIGmtaxezCJhZpEPfaul/B2mCTjWkGrxOMROAzeocrIY4pJ5cGmH8XYfGA+
WQOwe+OKHb33qak3mrgGxECv72R/h2PUH5PV14HEj+PW5S03qIHm3iisvGWo6+3C
efqZ9tsiWbPvbF3CFuECOgjUIu5YDf6K83H5/Lnaw9SnANuTj8t8I1yg/RmByWlx
9ucposBVht9h9TcFKNm+REfNCaYwQ3FukfGn/s3ih/iHNcGn1rGjh1t+vN4DNnLl
Ew3GTlSzJqzeO3QvstdrRDvvBNFGDZV6yyZBu3ogPaZc4WAHnHQ=
=suTg
-----END PGP SIGNATURE-----
